<?php
/**
 * Created by JetBrains PhpStorm.
 * User: guansong
 * Date: 17/2/28
 * Time: 下午2:55
 * To change this template use File | Settings | File Templates.
 */

namespace app\admin\controller;


class Login {
    public function login()
    {
        return view();
    }
    public function doLogin($loginname,$password)
    {
        $model = model("Users");
        $res = $model->where(["loginname"=>$loginname,"password"=>md5($password)])->find();
//        echo $model->getLastSql();
        if(empty($res))
        {
            echo "用户名或密码不正确";
        }
        else
        {
//            var_dump($res);
            //写入 session
            session("id",$res["id"]);
            session("loginname",$res["loginname"]);

            echo "登录成功！";
        }
    }
}